﻿using ProjBackEnd.Models.AppModel.AppUserModel;
using ProjBackEnd.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace ProjBackEnd.Controllers
{
    public class AppUserController : ApiController
    {
        /// <summary>
        /// 获取微信OpenID
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [System.Web.Http.HttpPost]
        [Route("api/AppUser/GetWeChatOpenid")]
        public HttpResponseMessage GetWeChatOpenid([FromBody] GetWeChatOpenidModel model)
        {
            AppUserService svc = new AppUserService();
            string result = svc.GetWeChatOpenid(model);
            return ControllerHelper.GetResponse(result); 
        }


        /// <summary>
        /// 微信授权登陆
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [System.Web.Http.HttpPost]
        [Route("api/AppUser/WechatLogin")]
        public HttpResponseMessage WechatLogin([FromBody] WechatLoginModel model)
        {
            AppUserService svc = new AppUserService();
            string result = svc.WechatLogin(model);
            return ControllerHelper.GetResponse(result);
        }

        /// <summary>
        /// 微信手机号授权登陆
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [System.Web.Http.HttpPost]
        [Route("api/AppUser/WechatPhoneLogin")]
        public HttpResponseMessage WechatPhoneLogin([FromBody] WechatLoginPhoneModel model)
        {
            AppUserService svc = new AppUserService();
            string result = svc.WechatPhoneLogin(model);
            return ControllerHelper.GetResponse(result);
        }

        /// <summary>
        /// APP用户登陆
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [System.Web.Http.HttpPost]
        [Route("api/AppUser/AppUserLogin")]
        public HttpResponseMessage AppUserLogin([FromBody] AppUserLoginModel model)
        {
            AppUserService svc = new AppUserService();
            string result = svc.AppUserLogin(model);
            return ControllerHelper.GetResponse(result);
        }
         


    }
}
